package sangpil.net
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import sangpil.events.XmlLoaderEvent;
	
	[Event(name="xmlComplete", type = "sangpil.events.XmlLoaderEvent")]
	public class XmlLoader extends EventDispatcher
	{
		
		private var urlLoader:URLLoader;
		
		public function XmlLoader()
		{
			super();
		}
		
		public function load(url:String):void
		{
			this.urlLoader = new URLLoader();
			this.urlLoader.addEventListener(Event.COMPLETE, onComplete);
			this.urlLoader.load(new URLRequest(url));
		}
		
		private function onComplete(e:Event):void
		{
			var xml:XML = new XML(this.urlLoader.data);
			this.dispatchEvent(new XmlLoaderEvent(xml, XmlLoaderEvent.XML_COMPLETE));
		}

	}
}